<%@ include file="/common/taglibs.jsp"%>
<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevent caching at the proxy server
%>

<head>
    <title><fmt:message key="articulolist.title"/></title>
    <meta name="heading" content="<fmt:message key='articulolist.heading'/>"/>    
</head>

<form:form id="articuloList">

	<fieldset style="width: 400px">
	<legend><fmt:message key="common.filtros.busqueda"/></legend>
	
		<br/><div>
			<fmt:message key="common.articulo"/><br/>
			<input type="text" id="deArticulo" name="deArticulo" class="text large"/>								
		</div><br/>	
		<div>
			<fmt:message key="common.codigo"/><br/>
			<input type="text" id="coCodigoArticulo" name="coCodigoArticulo" class="text large"/>			
		</div><br/>
		<div>
			<fmt:message key="common.categoria"/><br/>
			<select id="coCategoria" name="coCategoria" class="text large">
				<option value="0"><fmt:message key="label.itemdefault"/></option>
				<c:forEach var="categoria" items="${categorias}" varStatus="status">	
					<option value="${categoria.id}">${categoria.deCategoria}</option>
				</c:forEach>			
			</select>
		</div><br/>					
		
		<div>
			<fmt:message key="common.maneja.stock"/><br/>
			<select id="stManejaStock" name="stManejaStock" class="text large">
				<option value="-"><fmt:message key="label.itemdefault"/></option>
				<option value="PC"><fmt:message key="common.maneja.stock.punto.canje"/></option>
				<option value="AP"><fmt:message key="common.maneja.stock.almacen.principal"/></option>
				<option value="NM"><fmt:message key="common.no.maneja.stock"/></option>
				<option value="IN"><fmt:message key="common.maneja.premioinstantaneo"/></option>
				<option value="IV"><fmt:message key="common.maneja.premioinstantaneovale"/></option>
			</select>
		</div><br/>
		<div>
			<fmt:message key="common.maneja.serie"/><br/>
			<select id="stManejaSerie" name="stManejaSerie" class="text large">
				<option value="-"><fmt:message key="label.itemdefault"/></option>
				<option value="Y"><fmt:message key="common.yes"/></option>
				<option value="N"><fmt:message key="common.no"/></option>
			</select>
		</div><br/>				
		<div>
			<input type="button" onclick="buscarArticulos()" value="<fmt:message key="button.search"/>"/>
		</div>					
		</fieldset><br/><br/>

		<table id="articulos" cellpadding="0" class="table" cellspacing="0" style="width: 1100px" > 
			<thead> 
				<tr> 
		            <th scope="col"><fmt:message key="common.articulo"/></th>
		            <th scope="col"><fmt:message key="common.categoria"/></th>
		            <th scope="col"><fmt:message key="common.codigo.articulo"/></th>
		            <th scope="col"><fmt:message key="common.unidad.medida"/></th>
		            <th scope="col"><fmt:message key="common.maneja.tipoarticulo"/>?</th>            
		            <th scope="col"><fmt:message key="common.stock.actual"/></th>            
		            <th scope="col"><fmt:message key="common.stock.disponible"/></th>
		            <th scope="col"><fmt:message key="common.maneja.serie"/></th>
				</tr>
			</thead> 
			<tbody id="articulosbody">
				<tr id="pattern" style="display:none;">
					<td> 
						<span id="tableArticulo">Articulo</span>						
					</td>
					<td> 
						<span id="tableCategoria">Categoria</span>						
					</td>	
					<td> 
						<span id="tableCodigo">Codigo</span>						
					</td>	
					<td> 
						<span id="tableUnidadMedida">Unidad Medida</span>						
					</td>
					<td> 
						<span id="tableStock">Stock</span>						
					</td>						
					<td> 
						<span id="tableStockActual">Stock Actual</span>						
					</td>
					<td> 
						<span id="tableStockDisponible">Stock Disponible</span>						
					</td>
					<td> 
						<span id="tableManejaSerie">Maneja Serie</span>						
					</td>
				</tr> 	
				<c:forEach var="articulo" items="${articulos}" varStatus="status">	
					<c:choose>
						  <c:when test="${status.index % 2 == 0}"><tr class="odd" ></c:when>
						  <c:otherwise><tr class="even" ></c:otherwise>
					</c:choose>
		            	<td>
							<a href="javascript:void(0)" title="Valor" onClick="Modalbox.hide({beforeHide: function(){$('articuloCode').value = '${articulo.coCodigoArticulo}',
							$('articuloid').value = '${articulo.id}',$('articuloNameid').value = '${articulo.deArticulo}',$('stmanejastockpuntocanje').value = '${articulo.stManejaStockPuntoCanje}',
							$('stmanejastockalmprincipal').value = '${articulo.stManejaStockAlmPrincipal}',$('stnomanejastock').value = '${articulo.stNoManejaStock}',$('stinstantaneonormal').value = '${articulo.stInstantaneoNormal}',
							$('stinstantaneovale').value = '${articulo.stInstantaneoVale}'}})" >
		                    	${articulo.deArticulo}
		                    </a> 
							            	
						</td>
						<td>
		                    ${articulo.clpbCategoria.deCategoria}
		                </td> 
		                <td>
		                    ${articulo.coCodigoArticulo}
		                </td>
		                <td>
		                    ${articulo.clpdUnidadMedida.deUnidadMedida}
		                </td>
		                <td>
		                	<c:choose>
		                		<c:when test="${articulo.stManejaStockPuntoCanje eq true}">
		                			<fmt:message key='common.maneja.stock.punto.canje'/>
		                		</c:when>
		                		<c:when test="${articulo.stManejaStockAlmPrincipal eq true}">
		                			<fmt:message key='common.maneja.stock.almacen.principal'/>
		                		</c:when>                		
		                		<c:when test="${articulo.stNoManejaStock eq true}">
		                			<fmt:message key='common.no.maneja.stock'/>
		                		</c:when>
		                		<c:when test="${articulo.stInstantaneoNormal eq true}">
		                			<fmt:message key='common.maneja.premioinstantaneo'/>
		                		</c:when>
		                		<c:when test="${articulo.stInstantaneoVale eq true}">
		                			<fmt:message key='common.maneja.premioinstantaneovale'/>
		                		</c:when>
		                	</c:choose>
		                </td>                               
		                <td>
		                	${articulo.vaStockActual}
		                </td>
		                <td>
		                	${articulo.vaStockDisponible}
		                </td>
		                <td>
		                <c:choose>
		                	<c:when test="${articulo.stManejaSerie eq true}">
			                	<fmt:message key='common.yes'/>
		                	</c:when>
		                	<c:otherwise>
			                	<fmt:message key='common.no'/>
		                	</c:otherwise>
		                </c:choose>
		                </td>
		                
		           </tr>
		        </c:forEach>				
			</tbody>
		</table> 
</form:form>

<script type='text/javascript' src="<c:url value="/dwr/interface/ArticuloService.js"/>"></script>